package com.bawei.module_mine.tengxun.mvi.model.repository


import com.bawei.lib_net.RetrofitFactory
import com.bawei.module_mine.tengxun.mvi.model.api.LiveApi
import com.bawei.module_mine.tengxun.mvi.model.entity.CreateLiveRoomEntity
import com.bawei.module_mine.tengxun.mvi.model.entity.SendRedPacketEntity
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn


class LiveRepository {
    val api: LiveApi
    init {
        api= RetrofitFactory.getRetrofitFactory().create(LiveApi::class.java)
    }
    /**
     * 获取视频信息
     */
    suspend fun getSimpleType(createLiveRoom: CreateLiveRoomEntity) = flow {
        emit(api.createLiveRoom(createLiveRoom))
    }.flowOn(Dispatchers.IO)

    suspend fun deleteLiveRoom(roomId:String) = flow {
        emit(api.deleteLiveRoom(roomId))
    }.flowOn(Dispatchers.IO)

    suspend fun sendRedPacket(sendRedPacketEntity: SendRedPacketEntity)= flow {
        emit(api.postRedPacket(sendRedPacketEntity))
    }.flowOn(Dispatchers.IO)

}